/**
 * 评论
 */
const { router, libQuery } = require('../../lib/route')

libQuery((req, res, next, method) => {
  const params = req.params || {}
  const query = req.query || {}
  console.log('comments params=', params)
  console.log('comments query=', query)
  const id = params.id || 0
  // if (id === 0) {
  //   console.log('params=', rea.params)
  //   res.send(JSON.stringify({}))
  //   return
  // }

  const dataPath = '../datas/comments/' + id + '.js'
  console.log('/comments ->> dataPath=', dataPath)
  const data = require(dataPath)
  console.log('data=', data)
  if (data) {
    res.send(JSON.stringify(data))
  } else {
    res.renderError('没有找到 ' + dataPath)
  }
}, '/comments/:id/:comment?')

module.exports = router